package com.neusoft.dibuy.configuration;

import com.neusoft.dibuy.interceptor.IpCounterInterceptor;
import com.neusoft.dibuy.interceptor.MyIpCounterMvcConfig;
import com.neusoft.dibuy.properties.IpCounterProperties;
import com.neusoft.dibuy.service.IpCounterService;
import com.neusoft.dibuy.service.impl.IpCounterServiceImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@AutoConfiguration
@ConditionalOnClass(IpCounterService.class)
@EnableConfigurationProperties(value = IpCounterProperties.class)
@Import({ MyIpCounterMvcConfig.class , IpCounterInterceptor.class,
        IpCounterServiceImpl.class})
public class MyIpCounterAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public IpCounterService ipCounterService(){
        return new IpCounterServiceImpl();
    }
}
